<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String mainid = request.getParameter("mainid");
%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%@ include file="../jslib/jquerylib.jsp" %>
		 <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jqGrid/css/jqgrid.css"></link>
	  <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
	  <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
      <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
     <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
     <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>
	<style>
		.ui-jqgrid .ui-jqgrid-htable th div,.ui-jqgrid tr.ui-row-ltr td,.ui-jqgrid .ui-jqgrid-title ,.ui-paging-info,.ui-pg-table {font-size:12px;}
		.ui-jqgrid .ui-pg-input{height:18px;}
	</style>
    <script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    var stateValue="";
    var epids="${epids}";
    
    $(document).ready(function(){
    	var flowname='${flowname}';
	    var flag=0;
	    if(flowname==null||flowname=="")
	    {
	    	document.getElementById("flowname").value ="原始记录修改流程";
	    	document.getElementById("flag").value ="0";
	    	$("#flowname1").attr("disabled","disabled");
	    	$("#tr1").hide();
	    	$("#tr2").hide();
	    }
	    else{
	    	document.getElementById("flag").value ="1";
	    	var oruSqyy='${oru.oruSqyy}';
	    	document.getElementById("oruSqyy").value=oruSqyy;
	    	var oruBgms='${oru.oruBgms}';
	    	document.getElementById("oruBgms").value=oruBgms;
	    	var oruShyj='${oru.oruShyj}';
	    	document.getElementById("oruShyj").value=oruShyj;
	    	$("#flowname").attr("disabled","disabled");
	    	
	    }
    	    var editid="";
			var option1s = {
		    	   url:'<%=request.getContextPath() %>/oru!addORUData.action?steptype='+$("#steptype0").val(),
		    	    beforeSubmit: function() {
		    	    	var flag = checkForm();
		  	    	 	if(flag){
							return $('#pageFrom').validate().form();
		  	    	 	}
		   				return flag;
		    			
		    		},
		    	    dataType:'json',
		    	    success: function(data) {
		    	      if(data.result=='success'){
		    	        buttonDisabled();
						alert("提交成功");
						flowtaskid = data.taskid;
						changeButtonDisabled();
						api.close();
					    W.reload();
						
		    	      }else{
		    	      	alert("系统繁忙，请您稍后再试！");
		    	      	api.close();
						W.reload();
		    	      }
		    	}};
		$('#saveBtn').click(function(){
			    	$('#pageFrom').ajaxSubmit(options);
	 	            return false;
    	 });
		$('#savesaveBtn').click(function(){
	    	$('#pageFrom').ajaxSubmit(option1s);
	            return false;
        });
    	$('#closeBtn').click(function(){
    		api.close();
			//window.close();
		});
		
	});
	//grid失去焦点事件
	
  //执行大小
	function doResize() { 
		var ss = getPageSize(); 
		//alert(ss.WinH);
		
		//	 $("#gridTableAdd").jqGrid('setGridHeight', ss.WinH-345);
		//	 $("#gridTableAdd").jqGrid('setGridWidth', ss.WinW-30); 
			} 
    function buttonDisabled(){				
		for (i = 0;i < document.all.length; i++)
		{
			if (document.all[i].type == 'button' || document.all[i].type == 'submit' || document.all[i].type == 'reset')
			{
				document.all[i].disabled = true;
			}
		}			
	}
    function changeButtonDisabled(){	
		for (i = 0;i < document.all.length; i++)
		{
			if (document.all[i].type == 'button' || document.all[i].type == 'submit' || document.all[i].type == 'reset'){
				document.all[i].disabled = false;
			}
		}	
    } 

    function checkForm()
    {
       var flag ='0';
       $("textarea").each(function(){
	      if(flag=='0'){
	         var cnName = $(this).attr("cnname");
		     var len =$(this).attr("leg");
		     var realLength = getrealLength(this.value);
		     if(realLength>parseInt(len)){
		        if(cnName!=''&&len!=''){
		           alert(cnName+"最多为"+len+"个字符,字符输入超出限制!");
		           flag='1';
		        }
		        this.value = cutString1(this.value,parseInt(len));
		        $(this).focus();
		     }
	      }
	   });
	   if(flag=='1'){
	       return false;
	   }
	  // if($("#pageFrom").form('validate') == true){
	//	return $('#pageFrom').validate().form();
	  // }else{
		//	return $("#pageFrom").form('validate');
	 // }
     }
   	function checking(){
   		var flag = true;
		var epInshr = $("#epInshr").val();
	
		if(epInshr ==null || epInshr == "" ){
			alert("审核人不能为空！");
			$("#epInshr").focus();
    		return false;
		}
		
		
	}
	 
	function checkExp(inputData){ 
		var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
		var result = inputData.match(regEx);
		if (result == null) {
			return false;
		}
		return true;
	}
	function checkNum(inputData){
		var sNumber;
	    sNumber=Number(inputData);
	    if (isNaN(inputData)){
	       return false;
	     }
	    return true;
	}
	function countlen1(textarea){
	       var elem = event.relatedTarget || event.srcElement || event.target ||event.currentTarget;    
	        if(event.keyCode!=8)
			{
			  if (textarea.value.length> 249){
			        alert("最多为250个字符,字符输入超出限制!");
			        textarea.value=textarea.value.substring(0,249);
			    }
			    return true;
	 	    }
	}
		
	  //选择部门
	function selectdept(id)
	{
		var datas = window.showModalDialog("<%=request.getContextPath() %>/resource/choose/choose_organizationIndex.jsp?temp="+Math.round(Math.random()*10000),'',"dialogWidth=900px;dialogHeight=550px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("dept_"+id).value = json1.ORG_NAME;
			 document.getElementById(id).value = json1.ORG_ID;
		}
	}
	function getrealLength(values){
	       var realLength = 0, len =values.length, charCode = -1;
		   for (var i = 0; i < len; i++) {
		        charCode = values.charCodeAt(i);
		        if (charCode >= 0 && charCode <= 128){
		          realLength += 1;
		        }
		        else {
		         realLength += 2;
		        }
		   }
		   return realLength;
	   }
	//选择人员
	function selectperson(id)
	{
		 var users = window.showModalDialog("<%=request.getContextPath() %>/resource/choose/chooseAllUser.jsp", window, "dialogWidth:900px;status:no;dialogHeight:500px");
    	if (users != null) {
    		var userIds = [];
            var userNames = [];
            for(var i=0;i<users.length;i++){
                userIds.push(users[i]['userid']);
                userNames.push(users[i]['username']);
            }
			    $("#"+id).val(userNames.join());
		        $("#"+id+"ID").val(userIds.join());
		   }
	}

	function queryORUDetails(){
	//	var epInstoreno='${epInstoreno}';
		$.dialog({
	        title: '原始记录详情查看',
	        content: 'url:<%=request.getContextPath() %>/oru!queryOrUrl.action?oruUrl='+'${oruUrl}',
	       // content: 'url:<%=request.getContextPath() %>/view/org_filemodeedit_new.jsp?oruUrl='+'${oruUrl}',
	        okVal: false,//确定按钮文字
	        cancelVal: false,//取消按钮文字
	        min: true, //是否显示最小化按钮
	        max: false,//是否显示最大化按钮
	        fixed: false,//开启静止定位
	        lock: true,//开启锁屏
	        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
	        time: null,//设置对话框显示时间
	        resize: true,//是否允许用户调节尺寸
	        drag: true,//是否允许用户拖动位置
	        cache: false,//是否缓存iframe方式加载的窗口内容页
	        width: '900px',
	        stack:true,
	        zIndex: 2985,
	        closeOnEscape:true, 
	        height: 530
		});
					
	}
	function addBGSQ(){
		$.dialog({
	        title: '报告修改申请流程',
	        content: '报告修改111111111111111111111111111',
	        okVal: false,//确定按钮文字
	        cancelVal: false,//取消按钮文字
	        min: true, //是否显示最小化按钮
	        max: false,//是否显示最大化按钮
	        fixed: false,//开启静止定位
	        lock: true,//开启锁屏
	        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
	        time: null,//设置对话框显示时间
	        resize: true,//是否允许用户调节尺寸
	        drag: true,//是否允许用户拖动位置
	        cache: false,//是否缓存iframe方式加载的窗口内容页
	        width: '900px',
	        stack:true,
	        closeOnEscape:true, 
	        height: 530
		});
	}

	function changeChoose(val){
		if(val==1)
		{
			$("#td1").show();
			$("#td2").show();
			$("#tr3").show();
		    }
		else if(val==0)
		{
			$("#td1").hide();
			$("#td2").hide();
			$("#tr3").hide();
		    }
	}

   </script>
 	<style type="text/css">
 		body{
 			background:#ffffff; background-image:url(images/);
 		}
   		html{
		    overflow-x: hidden;
			overflow-y: hidden;
		}  	
		.formTableNew textarea{font-size: 12px;border: 1px solid #999;padding: 5px;width: 760px;-moz-border-radius: 3px;border-radius: 3px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;}
   </style>
  </head>
  
  <body>
 
<form id="pageFrom" action="" enctype="multipart/form-data" method="post">
        <input type="hidden" id="flag" name="flag" />
        <input type="hidden" name="flowid" id="flowid" value="${flowid}">
     	<input type="hidden" name="stateid" id="stateid" value="${stateid}">
     	<input type="hidden" name="taskinfoid" id="taskinfoid" value="${taskinfoid}" />
     	${steptcontent}
     	<input type="hidden" name="oruUrl" id="oruUrl" value="${oruUrl}">
     	<input type="hidden" name="oruId" id="oruId" value="${oru.oruId}">		
  	<table width='100%' border='0' align='center' class='formTableNew'>
  <tr> 
   <td style='text-align:right;width:120px;'>流程名称：</td>
   <td colspan='3'>
   <input type='hidden' id='flowname1' name='flowname' value='${flowname}' style='border: 1px solid #999;padding: 5px;width:705px'>
       <input type='text' id='flowname' name='flowname' value='${flowname}' style='border: 1px solid #999;padding: 5px;width:682px'>
    </td>
    </tr>
  <tr>
   <td align="right">申请人：</td>
     <td align="left">
      <input type="hidden" id="oruSqr" name="oruSqr" value="${userid}"/>
      <input type="text" disabled="disabled" class='finput'  readonly=readonly id="oruSqrname" name="oruSqrname"  value="${username}" />
     </td>
     <td align="right">申请日期：</td>
     <td align="left" >
     <input type="text" style="border: 1px solid #999;padding: 5px;width: 250px;"  id="oruSqsj" onClick="WdatePicker()" name="oruSqsj" value="${oruSqsj}"  />
     </td>
     </tr>
     <tr>
     <td align="right">申请原因：</td>
     <td align="left" colspan='3'>
     <textarea   rows="4" cols="3" class='ftextarea' id="oruSqyy" name="oruSqyy" style='border: 1px solid #999;padding: 5px;width:682px' ></textarea>
  	</td>
     </tr>
     <tr>
     
     <td align="right">委托单号：</td>
     <td align="left">
      <input type="hidden" id="oruWtdh" name="oruWtdh" value="${oruWtdh}"/>
      <input type="text" disabled="disabled" class='finput'  readonly=readonly id="oruWtdh1" name="oruWtdh1"  value="${oruWtdh}" />
      </td>
      <td align="right">委托单位：</td>
      <td align="left">
      <input type="hidden" id="oruWtdw" name="oruWtdw" value="${oruWtdwid}"/>
      <input type="text" disabled="disabled" style="border: 1px solid #999;padding: 5px;width: 250px;"  readonly=readonly id="dept_oruWtdw" name="dept_oruWtdw" value="${oruWtdw}"/>
      <img src="<%=request.getContextPath() %>/images/xh.png"  align="absmiddle"></img>
   	  <img src="<%=request.getContextPath() %>/web/images/form_icon_1.gif" style="cursor:hand; vertical-align: middle;" onclick="selectdept('oruWtdw')" />
     </td>
     </tr> 
     <tr>
     <td align="right">原始记录编号：</td>
     <td align="left" colspan="3">
      <input type="hidden" id="oruCode" name="oruCode" value="${oruCode}"/>
      <input type="text" disabled="disabled" class='finput'  readonly=readonly id="oruCode1" name="oruCode1"  value="${oruCode}" />
      &nbsp;&nbsp;<input id="query" type='button' value='查看原始记录详细' onclick='queryORUDetails()' class='button_b' />
      </td>
     </tr>
     <tr>
      <td align="right">修改检测报告：</td><td align="left">
     <select id="isEditBG"  class='fselect' onchange="changeChoose(this.value)" name="isEditBG" value="${oru.oruIsEditBg}" style="border: 1px solid #999;padding: 5px;width: 250px;"  >
     <option value="1">是</option>
     <option value="0">否</option>
     </select></td>
     <td align="right" id="td1" >报告识别号：</td>
     <td align="left" id="td2" >
       <input type="text"  id="oruBgsbh" name="oruBgsbh" value="${oru.oruBgsbh}" style="border: 1px solid #999;padding: 5px;width: 250px;"/>
     </td>
     </tr>
      <tr  id="tr3">
	  <td align="right">报告描述：</td>
         <td colspan="3" align="left">
         <textarea   rows="3" cols="2" class='ftextarea' id="oruBgms" name="oruBgms" style='border: 1px solid #999;padding: 5px;width:500px' ></textarea>
      &nbsp;&nbsp;<input id="queryBG" type='button' value='添加报告修改申请流程' onclick='addBGSQ()' class='button_b' />
      </td>
	 </tr>
	
	<tr id="tr1">
	  <td align="right">审核人：</td>
       <td align="left">
       <input type="hidden" id="oruShr" name="oruShr" value="${oruShr}"/>
      <input disabled="disabled" style="border: 1px solid #999;padding: 5px;width: 250px;" type="text" id="oruShr1" name="oruShr1" value="${oruShrname}" readOnly class='easyui-validatebox'  required missingMessage='必填' />
     </td>
     <td align="right">审核日期：</td>
     <td align="left">
     <input  type="hidden" id="oruShsj" onClick="WdatePicker()" name="oruShsj" value="${oru.oruShsj}"  />	
     <input disabled="disabled" style="border: 1px solid #999;padding: 5px;width: 250px;" type="text" id="oruShsj1" onClick="WdatePicker()" name="oruShsj1" value="${oru.oruShsj}"  />	
	 </tr>
	 <tr  id="tr2">
	  <td align="right">审核意见：</td>
         <td colspan="3" align="left">
         <textarea disabled="disabled"  rows="3" cols="3" class='ftextarea' id="oruShyj" name="oruShyj"  ></textarea>
     </td>
	 </tr>
	  <tr id="tr4">
  			  <td align="right">选择审核人：</td>
  			  <td align="left">
  			  	 <input type="hidden" id="userID" name="userID" />
  			  	 <input  type="text"  id="user" name="user" maxlength="50" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;" />
  			     <img src="<%=request.getContextPath() %>/images/xh.png"  align="absmiddle"></img>
  			    <img src="<%=request.getContextPath() %>/web/images/form_icon_1.gif" style="cursor:hand; vertical-align: middle;" onclick="selectperson('user')" />
  			  </td>
  	</tr>
		</table>
	<!--	<table id="gridTableAdd" width="100%"  border="10" align="center" class="formTableNew">
		</table>-->
		<table width="100%" border="0" align="center" class="formTableNew">
		  <tr>
			<td align="center">
		<!--<input id="saveBtn" type="button" value="提 交" class="form_bt_orange" />-->
			<input id='savesaveBtn' type='button'  value='提交' class='form_bt_orange' />   	
		    <input type="button" id="closeBtn" value="取 消" class="form_bt_grey" />
		    </td>
		  </tr>
		  
		</table>
	<!--表单结束-->
	</form>
  </body>
</html>
